﻿
Imports System.IO
Imports std
Imports xmlctrl
Imports xhtmlctrl

Public Class delayRedirector
    Inherits container

    Public originalUrl As String = Nothing
    Public redirectReason As String = "request is retired, please use the new link as"
    Private delayjump As delayJump = Nothing

    Public Sub New(Optional ByVal buff As Stream = Nothing)
        MyBase.New(buff)
        delayjump = New delayJump(buff)
    End Sub

    Protected Overrides Function render(ByVal compress As Boolean) As Boolean
        Dim page As xhtmlpage = Nothing
        page = New xhtmlpage(output())
        addchild(page)
        page.title().text = "delayRedirector - " + applicationSign()

        page.head().addchild(delayjump)

        Dim xmltext As xmltext = Nothing
        If Not isemptystring(originalUrl) Then
            xmltext = New xmltext(output())
            xmltext.text = "url " + originalUrl + character.blank + redirectReason
            page.body().addchild(xmltext)
            page.body().addchild(New br(output()))
        End If

        Dim a As a = Nothing
        a = New a(output())
        a.text = destination
        a.href = destination
        page.body().addchild(a)
        page.body().addchild(New br(output()))

        xmltext = New xmltext(output())
        xmltext.text = "this page will be automatically redirected to new destination in " _
                        + Convert.ToString(delay) + " seconds."
        page.body().addchild(xmltext)

        Return MyBase.render(compress)
    End Function

    Public Property delay() As Int64
        Get
            Return delayjump.delay
        End Get
        Set(ByVal value As Int64)
            copy(delayjump.delay, value)
        End Set
    End Property

    Public Property destination() As String
        Get
            Return delayjump.destination
        End Get
        Set(ByVal value As String)
            copy(delayjump.destination, value)
        End Set
    End Property

End Class
